Rewrite for readability
authorMohd Tarmizi <mohtar@users.noreply.github.com>
Mon, 13 Apr 2015 17:44:20 +0000 (01:44 +0800)
committerMohd Tarmizi <mohtar@users.noreply.github.com>
Tue, 14 Apr 2015 07:46:06 +0000 (15:46 +0800)
src/cargo/ops/cargo_rustc/context.rs

index c7cfbfe775177cbe3699d8820c6b070843331104..3fcf058de96b5be3731209982c63e669ea0663dc 100644 (file)
@@ -338,23 +338,24 @@ impl<'a, 'b: 'a> Context<'a, 'b> {
             Some(deps) => deps,
         };
         let mut ret = deps.map(|id| self.get_package(id)).filter(|dep| {
-            let pkg_dep = pkg.dependencies().iter().find(|d| {
-                d.name() == dep.name() &&
+            pkg.dependencies().iter().filter(|d| {
+                d.name() == dep.name()
+            }).any(|d| {
 
                 // If this target is a build command, then we only want build
                 // dependencies, otherwise we want everything *other than* build
                 // dependencies.
-                target.is_custom_build() == d.is_build() &&
+                let is_correct_dep = target.is_custom_build() == d.is_build();
 
                 // If this dependency is *not* a transitive dependency, then it
                 // only applies to test/example targets
-                (d.is_transitive() ||
-                 target.is_test() ||
-                 target.is_example() ||
-                 profile.test)
-            });
+                let is_actual_dep = d.is_transitive() ||
+                                    target.is_test() ||
+                                    target.is_example() ||
+                                    profile.test;
 
-            pkg_dep.is_some()
+                is_correct_dep && is_actual_dep
+            })
         }).filter_map(|pkg| {
             pkg.targets().iter().find(|t| t.is_lib()).map(|t| {
                 (pkg, t, self.lib_profile(pkg.package_id()))